/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.TOOL;

import GUI.TOOL.WriteExcel;
import javax.swing.*;
import java.io.*;
import jxl.write.WriteException;

/**
 *
 * @author HUE
 */
public class XuatExcel {

	public XuatExcel() {
	}

	public void exportTable(JTable table, File file) {
		WriteExcel out = null;

		try {
			out = new WriteExcel();
			out.xuatExcel(table, file);

		} catch (IOException e) {
		} catch (WriteException ex) {
		}

//		FileWriter out = null;
//		TableModel model = table.getModel();
//		try {
//			out = new FileWriter(file);
//
//		} catch (Exception e) {
//			System.out.print("Không thể mở file");
//			return;
//		}
//
//		for (int i = 0; i < model.getColumnCount(); i++) {
//			out.write(model.getColumnName(i) + "\t");
//		}
//		out.write("\n");
//
//		for (int i = 0; i < model.getRowCount(); i++) {
//			for (int j = 0; j < model.getColumnCount(); j++) {
//				//   I added this check for the ISBN conversion
//				if (j == 0) {
//					//    the book Title
//					//	Scanner input = new Scanner(is, "UTF-8");
//					out.write(model.getValueAt(i, j).toString() + "\t");
//				} else {
//					out.write(model.getValueAt(i, j).toString() + "\t");
//				}
//			}
//			out.write("\n");
//		}
//		out.close();
//		System.out.println("write to " + file);

	}
}
